package _interview75;

import _object.ListNode;

/**
 * 328. 奇偶链表
 */
public class No328 {
    public ListNode oddEvenList(ListNode head) {
        if (head == null) return null;
        ListNode cur = head, nex = head.next;
        ListNode sent = new ListNode(-1, cur), sentNex = new ListNode(-1, nex);

        while (nex != null && nex.next != null) {
            cur.next = cur.next.next;
            nex.next = nex.next.next;
            cur = cur.next;
            nex = nex.next;
        }
        cur.next = sentNex.next;

        return sent.next;
    }
}
